########################################################
# Part of MILIM NIRDAFOT project.
# Written by H. Magal, 2014
# See details on the project at the site:
#   https://sites.google.com/site/nirdafotdownloads/home
########################################################

import wx
import constants


# main list frame class
class FullListFrame (wx.Frame):
    """ make a frame, inherits wx.Frame """
    def __init__ (self, mainFrame):
        if constants.platform_is_Win is True:               # we change it only for current frame
            local = wx.Locale (wx.LANGUAGE_HEBREW)          # set right to Left Locale. It is a MUST for windows
        ds = wx.DisplaySize()   # get screen dimensions
        height = ds [1]
        width = ds [0]
        frame_width = (width*9) / 10
        frame_height = (height*9) / 10
        # create a frame, no parent, default to wxID_ANY. The frame cannot be resized/maximized
        # the frame is generated to be positioned at the screen regarding the screen properties
        wx.Frame.__init__ (self, None, wx.ID_ANY, 'Full List', pos=(width/20, height/20), size=(frame_width, frame_height),
                           style=(wx.CAPTION | wx.CLOSE_BOX | wx.CLIP_CHILDREN))

        panel = wx.Panel (self)
        sizer = wx.BoxSizer (wx.VERTICAL)

        db = mainFrame.db
        fullList = db.getWholeList ()
        fulltext = ''
        for row in fullList:                                    # row is a list of words
            for word in row:
                if row.index (word) == (len (row) -1):          # the last word at each row is the non-concurrent int. needs special treatment
                    fulltext = fulltext + '  (' + word + ')\n'
                else:
                    fulltext = fulltext + ' ' + word            # add words into a line
        fulltext = fulltext.rstrip ('\n')                       # remove trailing new line to make is cleaner

        text = wx.TextCtrl (panel, style=wx.SIMPLE_BORDER | wx.VSCROLL | wx.TE_READONLY | wx.TE_MULTILINE | wx.TE_WORDWRAP,
                            size=((frame_width*99)/100, (frame_height*99)/100))
        fnt = text.GetFont ()
        sz = fnt.GetPointSize ()                                # increase font size by *3
        fnt.SetPointSize (sz*2)
        text.SetFont (fnt)

        text.AppendText (fulltext)
        text.SetInsertionPoint (0)
        text.Refresh ()
        sizer.Add (text, flag=wx.ALL | wx.EXPAND, border=4)

        panel.SetSizer (sizer)
        panel.Layout ()
        self.Show (True)                                        # show the frame